function init() {
	console.log("Initilizing Custom Bindings");
	var unavailableDates = ["25-8-2013", "24-8-2013", "29-8-2013"];

	/* Custom Binding for Date Picker */
	ko.bindingHandlers.jqueryUIBindings = {
		init : function(element, valueAccessor) {
			// This will be called when the binding is first applied to an element
			// Set up any initial state, event handlers, etc. here
			console.log("init date binding", academicYearStartDate,academicYearEndDate);

			holidayStartDate = academicYearStartDate;
			holidayEndDate = academicYearEndDate;

			jQuery(element).datepicker({
				changeMonth : true,
				changeYear : true,
				dateFormat : "dd/mm/yy",
				minDate : academicYearStartDate,
				maxDate : academicYearEndDate,
				beforeShowDay : highlightDays,
				prevText:'Prev Month',
				nextText:'Next Month'
			});
		},
		update : function(element, valueAccessor, allBindingsAccessor, viewModel, bindingContext) {
			//console.log("update date binding", valueAccessor());
			//console.log("myAcademicYearModel :: ", myAcademicYearModel);
			console.log("Update date binding", valueAccessor());
				
			myAcademicYearModel.onDateChange(element)

			// This will be called once when the binding is first applied to an element,
			// and again whenever the associated observable changes value.
			// Update the DOM element based on the supplied values here.

			//	console.log("element:", jQuery(element).datepicker("getDate"));
			/*	if (valueAccessor() == "start") {
			 holidayStartDate = jQuery(element).datepicker("getDate");
			 console.log("holidayStartDate:", holidayStartDate);

			 jQuery(element).datepicker("destroy");
			 jQuery(element).datepicker({
			 changeMonth : true,
			 changeYear : true,
			 dateFormat : "dd/mm/yy",
			 minDate : holidayStartDate,
			 maxDate : academicYearEndDate
			 });

			 } else if (valueAccessor() == "end") {
			 holidayEndDate = jQuery(element).datepicker("getDate");
			 console.log("holidayEndDate:", holidayEndDate);
			 jQuery(element).datepicker("destroy");
			 jQuery(element).datepicker({
			 changeMonth : true,
			 changeYear : true,
			 dateFormat : "dd/mm/yy",
			 minDate : academicYearStartDate,
			 maxDate : holidayEndDate
			 });
			 }

			 jQuery(element).datepicker({
			 changeMonth : true,
			 changeYear : true,
			 dateFormat : "dd/mm/yy",
			 minDate : academicYearStartDate,
			 maxDate : academicYearEndDate
			 });*/
		}
	};

/*	function highlightDays(date) {
		console.log("----->", myAcademicYearModel.holidays(), myEventsModel);
		console.log(date)
		var rtnVal = true;
		var rtnClass = "";
		var toolTip = "";

		//dmy = date.getDate() + "/" + (date.getMonth() + 1) + "/" + date.getFullYear();
		ko.utils.arrayForEach(myAcademicYearModel.holidays(), function(item) {
			var itemEvent = item;
			console.log("item Holiday:", itemEvent.startDate());
			var strArr1 = itemEvent.startDate().split("/");
			var strArr2 = itemEvent.endDate().split("/");
			// years, months, date
			var startDate = new Date(strArr1[2], Number(strArr1[1] - 1), strArr1[0]);
			var endDate = new Date(strArr2[2], Number(strArr2[1] - 1), strArr2[0]);

			if (startDate <= date && date <= endDate) {
	//			rtnVal = false;
				rtnClass = "create_ayp_holiday";
				toolTip = itemEvent.title();

				//break
				//return [false, "nonAvailable", "Unavailable"];
			}
		});

		ko.utils.arrayForEach(myAcademicYearModel.eventData(), function(item) {
			var itemEvent = item;

			if (ko.isObservable(itemEvent.startDate)) {
				console.log("observable item", itemEvent)
				var strArr1 = itemEvent.startDate().split("/");
				var strArr2 = itemEvent.endDate().split("/");

			} else {
				console.log("Non observable item", itemEvent)
				var strArr1 = itemEvent.startDate.split("/");
				var strArr2 = itemEvent.endDate.split("/");
			}
			// years, months, date
			var startDate = new Date(strArr1[2], Number(strArr1[1] - 1), strArr1[0]);
			var endDate = new Date(strArr2[2], Number(strArr2[1] - 1), strArr2[0]);

			if (startDate <= date && date <= endDate) {
				rtnVal = false;
				rtnClass = "create_ayp_event";
				if (ko.isObservable(itemEvent.startDate)) {
					toolTip = itemEvent.title();

				} else {
					toolTip = itemEvent.title;
				}
				//break
				//return [false, "nonAvailable", "Unavailable"];
			}
		});

	//	if (rtnVal) {
	//		return [rtnVal, ""];
	//	} else {

			return [rtnVal, rtnClass, toolTip];*/
	//	}
		/*if ($.inArray(dmy, unavailableDates) == -1) {
		 return [true, "available"];
		 } else {
		 return [false, "nonAvailable", "Unavailable"];
		 }*/

//	}

	/* Custom Binding for Button */
	ko.bindingHandlers.btnCustBinding = {
		init : function(element, valueAccessor) {
			// This will be called when the binding is first applied to an element
			// Set up any initial state, event handlers, etc. here

			//  jQuery(element).button();
		},
		update : function(element, valueAccessor, allBindingsAccessor, viewModel, bindingContext) {
			// This will be called once when the binding is first applied to an element,
			// and again whenever the associated observable changes value.
			// Update the DOM element based on the supplied values here.
		}
	};

	/* Custom Binding for Accordion */
	ko.bindingHandlers.jqAccordion = {

		init : function(element, valueAccessor) {
			console.log("-----> init");
			var options = valueAccessor(), accordianOptions = options.options;

			jQuery(element).accordion(accordianOptions);

			jQuery(element).bind("valueChanged", function() {

				ko.bindingHandlers.jqAccordion.update(element, valueAccessor);

			});
			jQuery(element).accordion({
				heightStyle : "content"
			});
		},
		update : function(element, valueAccessor) {
			console.log("-----> update");
			var options = valueAccessor(), accordianOptions = options.options, dependency = ko.utils.unwrapObservable(options.updateOn);
			jQuery(element).accordion('destroy').accordion(accordianOptions);
		}
	};

	/* Custom Binding for DropDown */
	ko.bindingHandlers.preSelect = {
		update : function(element, valueAccessor, allBindingsAccessor, viewModel, bindingContext) {

			var val = ko.utils.unwrapObservable(valueAccessor());
			var updateRequired = false;

			for (var i = 0; i < bindingContext.$parent.gradesList().length; i++) {
				if (val.value == bindingContext.$parent.gradesList()[i].ceGradeId) {
					setOptionNodeSelectionState(jQuery(element)[0].options[i], true);
					updateRequired = true;
					break;
				}
			}

			if (updateRequired) {
				var options = allBindingsAccessor().options;
				var selected = ko.utils.arrayFirst(options(), function(item) {
					return ko.utils.unwrapObservable(val.value) == item["ceGradeId"];
				});
				if (ko.isObservable(bindingContext.$data["selectedGrade"])) {
					bindingContext.$data["selectedGrade"](selected);
					// here we write the correct object back into the $data
				} else {
					bindingContext.$data["selectedGrade"] = selected // here we write the correct object back into the $data
				}
			}

			/*  var newOptions = element.getElementsByTagName("option");
			 var updateRequired = false;
			 for (var i = 0, j = newOptions.length; i < j; i++) {
			 if (ko.utils.unwrapObservable(val.value) == ko.selectExtensions.readValue(newOptions[i])[val.key]) {
			 if (!newOptions[i].selected)
			 {
			 ko.utils.setOptionNodeSelectionState(newOptions[i], true);//only sets the selectedindex, object still holds index 0 as selected
			 updateRequired = true;
			 }
			 }
			 }
			 if (updateRequired)
			 {
			 var options = allBindingsAccessor().options;
			 var selected = ko.utils.arrayFirst(options, function (item) {
			 return ko.utils.unwrapObservable(val.value) == item[val.key];
			 });
			 if (ko.isObservable(bindingContext.$data[val.propertyName])) {
			 bindingContext.$data[val.propertyName](selected); // here we write the correct object back into the $data
			 } else {
			 bindingContext.$data[val.propertyName] = selected; // here we write the correct object back into the $data
			 }
			 }
			 */
		}
	}
	
	  function setOptionNodeSelectionState(optionNode, isSelected) {
            // IE6 sometimes throws "unknown error" if you try to write to .selected directly, whereas Firefox struggles with setAttribute. Pick one based on browser.
            if (navigator.userAgent.indexOf("MSIE 6") >= 0)
                optionNode.setAttribute("selected", isSelected);
            else
                optionNode.selected = isSelected;
        }
}
